const express = require('express');
const { authenticateToken, requireAdmin } = require('../middleware/auth');
const CourseController = require('../controllers/admin/CourseController');
const UserController = require('../controllers/admin/UserController');

const router = express.Router();

// 课程管理路由
router.get('/courses', authenticateToken, requireAdmin, CourseController.index);
router.get('/courses/add', authenticateToken, requireAdmin, CourseController.add);
router.post('/courses', authenticateToken, requireAdmin, CourseController.addPost);
router.get('/courses/:id/edit', authenticateToken, requireAdmin, CourseController.edit);
router.put('/courses/:id', authenticateToken, requireAdmin, CourseController.editPost);
router.delete('/courses/:id', authenticateToken, requireAdmin, CourseController.del);
router.put('/courses/:id/status', authenticateToken, requireAdmin, CourseController.setStatus);
router.post('/courses/batch', authenticateToken, requireAdmin, CourseController.batch);
router.get('/courses/stats', authenticateToken, requireAdmin, CourseController.stats);

// 用户管理路由
router.get('/users', authenticateToken, requireAdmin, UserController.index);
router.get('/users/add', authenticateToken, requireAdmin, UserController.add);
router.post('/users', authenticateToken, requireAdmin, UserController.addPost);
router.get('/users/:id/edit', authenticateToken, requireAdmin, UserController.edit);
router.put('/users/:id', authenticateToken, requireAdmin, UserController.editPost);
router.delete('/users/:id', authenticateToken, requireAdmin, UserController.delete);
router.put('/users/:id/ban', authenticateToken, requireAdmin, UserController.ban);
router.put('/users/:id/unban', authenticateToken, requireAdmin, UserController.cancelBan);
router.put('/users/:id/reset-password', authenticateToken, requireAdmin, UserController.resetPassword);
router.get('/users/stats', authenticateToken, requireAdmin, UserController.stats);

// 仪表板
router.get('/dashboard', authenticateToken, requireAdmin, (req, res) => {
  res.json({ code: 0, message: '管理员仪表板', data: {} });
});

module.exports = router; 